package com.fair.concurrency.example;

import java.util.concurrent.ExecutionException;

/**
 * @author 朝花不迟暮
 * @version 1.0
 * @date 2020/11/13 13:20
 */
public class TestCallable
{
    public static void main(String[] args) throws ExecutionException, InterruptedException
    {
        new Thread2().start();
    }
}

class Thread1 extends Thread{
    public Thread1()
    {
        System.out.println("Thread1的构造方法由【"+Thread.currentThread().getName()+"】调用");
    }

    static {
        System.out.println("Thread1的静态块由【"+Thread.currentThread().getName()+"】调用");
    }

    @Override
    public void run()
    {
        Thread thread = new Thread();
        thread.setName("Thread1");
        System.out.println("Thread1的普通方法由【"+Thread.currentThread().getName()+"】调用");
        thread.start();
    }
}

class Thread2 extends Thread{
    private Thread1 thread1;

    public Thread2()
    {
        System.out.println("Thread2的构造方法由【"+Thread.currentThread().getName()+"】调用");
    }

    static {
        System.out.println("Thread2的静态块由【"+Thread.currentThread().getName()+"】调用");
    }

    @Override
    public void run()
    {
        new Thread1();
        Thread thread = new Thread();
        thread.setName("Thread2");
        System.out.println("Thread2的普通方法由【"+Thread.currentThread().getName()+"】调用");
        thread.start();
    }

}
